'use strict'
let data={}
class mymessage{
  constructor (mdb) {
    this.mdb = mdb || null
  }
  async post(c){
    console.log('----------------')
    //console.log(c);
    data.treeid=JSON.parse(c).treeid;
    data.userid=JSON.parse(c).userid;
    console.log('这是处理后的data数据：',data)
    return 'ok'
  }
  async get(c) {
    try{
      let sql=`select * from tree_message where treeid=${data.treeid} and userid=${data.userid}`
      let r=await this.mdb.query(sql)
      let result=r['rows']
      if(result.rowCount<=0){
        return ('failed register',400)
      }
      return result

    }catch(e){
      return ('failed',400)
    }
  }
 
}

module.exports = mymessage
